// DisplayLayout.h
#ifndef DISPLAY_LAYOUT_H
#define DISPLAY_LAYOUT_H

#include <FastLED.h>

class DisplayLayout {
public:
    DisplayLayout(uint16_t width, uint16_t height);
    
    void setTimePosition(uint8_t x, uint8_t y);
    void setDatePosition(uint8_t x, uint8_t y);
    void setWeekPosition(uint8_t y); // 添加设置星期位置的方法
    
    uint8_t getTimePositionX() { return timeX; }
    uint8_t getTimePositionY() { return timeY; }
    uint8_t getDatePositionX() { return dateX; }
    uint8_t getDatePositionY() { return dateY; }
    uint8_t getWeekPositionY() { return weekY; } // 添加获取星期位置的方法
    
    void drawDigit(CRGB* leds, uint8_t x, uint8_t y, uint8_t num, CRGB color);
    void drawSmallDigit(CRGB* leds, uint8_t x, uint8_t y, uint8_t num, CRGB color);
    void drawColon(CRGB* leds, uint8_t x, uint8_t y, CRGB color);
    void drawCalendarIcon(CRGB* leds, uint8_t x, uint8_t y, CRGB color);
    void drawWeekIndicator(CRGB* leds, uint8_t dayOfWeek, CRGB activeColor, CRGB inactiveColor); // 添加星期指示器方法
    int getLedIndex(uint8_t x, uint8_t y);
    uint16_t getWidth() { return width; }
    uint16_t getHeight() { return height; }
    uint16_t getTimeDisplayWidth() { return 28; }
    uint16_t getDateDisplayWidth() { return 22; }
    
    // 添加边界检查方法
    bool isValidPosition(uint8_t x, uint8_t y) {
        return (x < width && y < height);
    }

private:
    uint16_t width;
    uint16_t height;
    
    static const bool digitPatterns[10][7][3];
    static const bool smallDigitPatterns[10][5][3];
    
    uint8_t timeX = 0;
    uint8_t timeY = 0;
    uint8_t dateX = 0;
    uint8_t dateY = 1; // 默认下移一位
    uint8_t weekY = 7; // 默认在底部
    
    int calculateIndex(uint8_t x, uint8_t y);
    
    // 星期指示器参数
    const uint8_t weekLineWidth = 3;  // 每条线宽度
    const uint8_t weekSpacing = 1;    // 间隔
};

#endif